/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Business;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Rubik Levitsky
 */
public class FrameHandler
{
    public static final int NOTOOLBAR = 0;
    public static final int TOOLBAR = 1;


    private static FrameHandler _fHandler;

        private int _fType = 0;                             // 0 or 1, the current index of the frame.
        private FrameType frames[];


        private FrameHandler()
        {
            frames = new FrameType[2];
            frames[0] = new NoToolbarFrame();
            frames[1] = new ToolbarFrame();
            this._fType = 0;
        }

        public static FrameHandler getFrameHandler()
        {
                if(_fHandler == null)
                {
                    _fHandler = new FrameHandler();
                }
                return _fHandler;
        }

       public synchronized void changeToOtherTypeOfFrame(int type)
       {
             this.frames[this._fType].dispose();
            this._fType = type;
            this.frames[this._fType].initiateFrame();
       }

    public synchronized void initiateFrameHandler()
    {
        this.frames[this._fType].initiateFrame();
    }

    public synchronized void  changeCurrentFrame(JFrame frame)
    {
        this.frames[this._fType].changeCurrentFrame(frame);
    }

    public synchronized void showErrorMessage(String error)
    {
        this.frames[this._fType].showErrorMessage(error);
    }

    public void showInfoMessage(String str) {
        this.frames[this._fType].showInfoMessage(str);
    }


}
